﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;
namespace UI
{
    public partial class LoginForm : UIForm
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            string userName = uiTextBox1.Text.Trim();
            string password = uiTextBox2.Text.Trim();
            FCustomMain frm = new FCustomMain();
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("用户名和密码不能为空！");
                return;
            }

            // 这里添加你的登录验证逻辑
            // 例如连接数据库进行验证
            bool isLoginSuccessful = ValidateLogin(userName, password);

            if (isLoginSuccessful)
            {
                MessageBox.Show("登录成功！");
               
                this.Hide(); //隐藏这个窗体
                frm.Show();
                
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }



        private bool ValidateLogin(string userName, string password)
        {
            // 连接数据库进行验证，返回验证结果
            // 这里只是一个示例，实际应用中需要根据你的数据库结构编写查询代码
            return userName == "admin" && password == "123456";
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
